<template>
  <div class="app-container">
    <div class="content-step">
        <div class="step">
          <el-steps :active="active" finish-status="success">
            <el-step title="输入域名"></el-step>
            <el-step   title="域名解析"></el-step>
            <el-step title="完成"></el-step>
        </el-steps>
        </div>
    </div>
    <div class="content">
      <div class="content-title">域名</div>
      <div class="title">{{DNSBind ? DNSBind.domainName: ''}} <span class="title-title" @click="handleReturn">修改</span></div>
      <div class="container">
      <el-table :data="DNSBind ? DNSBind.dnsRecords: []" style="width: 100%">
    <el-table-column
      label="记录类型">
      <template slot-scope="scope">
        <span style="margin-left: 10px">{{ scope.row.recordType }}</span>
      </template>
    </el-table-column>
    <el-table-column
      label="主机记录">
      <template slot-scope="scope">
        <span style="margin-left: 10px">{{ scope.row.recordHost }}</span>
      </template>
    </el-table-column>
    <el-table-column
      label="当前记录值">
      <template slot-scope="scope">
        <span style="margin-left: 10px">{{ scope.row.currentValue ? scope.row.currentValue : '空' }}</span>
      </template>
    </el-table-column>
    <el-table-column label="正确记录值">
      <template slot-scope="scope">
          <span>{{scope.row.recordValue}}</span>
        <el-button
          type="text"
          icon="el-icon-document-copy"
          @click="handleCopy(scope.row.recordValue)"></el-button>
      </template>
    </el-table-column>
  </el-table>
  </div>
  <div class="fotter">未连接！A和CNAME记录值不正确，请复制正确记录值。遇到问题？点击查看<a href="" class="fotter-title">帮助文档</a></div>
  </div>
  <div class="btn">
      <el-button  @click="handleReturn">上一步</el-button>
      <el-button type="primary" @click="handleEnd" :loading="submitLoading">{{submitLoading ? '验证中' : '验证'}}</el-button>
    </div>
  </div>
</template>

<script>
import { bindDomainName } from '@/api/domain';

export default {
    name: 'domain-name-add',
    data () {
        return {
            DNSBind: this.$route.query.DNSBind,
            input: '',
            active: 2,
            params: {},
            config: {},
            submitLoading: false,
            settingVisible: false
        };
    },
    methods: {
        handleReturn () {
            this.$router.push({name: 'domain-name-add'});
        },
        handleEnd () {
            let data = {
                domainName: this.DNSBind.domainName,
                siteId: this.siteId
            };
            this.submitLoading = true;
            bindDomainName(data).then(res => {
                if (res.data.binded) {
                    this.$router.push({name: 'domain-name-complete', params: {DNSBind: res.data}});
                } else {
                    this.DNSBind = res.data;
                }
                this.submitLoading = false;
            });
            // this.$router.push({name: 'domain-name-complete'});
        },
        handleCopy (value) {
            this.$copyText(value).then(() => {
                this.$message({
                    message: '复制成功',
                    type: 'success'
                });
            });
        }
    },
    computed: {
        siteId () {
            return this.$store.state.user.siteId;
        }
    }
};
</script>

<style lang="scss" scoped>
.btn{
  margin: 30px;
  padding: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  // justify-content:flex-end;
}
.content {
  // height: 500px;
  margin: 30px ;
  display: flex;
  flex-direction: column;
  background-color: #ffffff;
}
.content-step{
  display: -webkit-box;
 -webkit-box-pack: center;
  justify-content: center;
  margin: 20px 30px 20px 30px;
}
.step{
  height: 100%;
  width: 60%;
}
.content-title{
    padding: 30px 0 0 30px;
    font-size: 18px;
    font-weight: 500;
    color:#30344f
}
.title{
    font-size: 16px;
    color:#30344f;
    padding: 15px 0 0 30px;
}
.title-title{
    font-size: 14px;
    margin-left: 10px;
    color: rgb(75, 75, 216);
    cursor: pointer;
}
.container {
  margin: 30px;
  display: flex;
  flex-direction: row;
}
.fotter{
    padding: 5px 0 0 30px;
    font-size: 14px;
}
.fotter-title{
    margin-left: 10px;
    font-size: 14px;
    color: rgb(75, 75, 216);
}
</style>
